﻿/* @File:       global-fun.js
 * @Purpose:    provide common global functions for std library
 */

/* @Function:   overlabel
 * @Purpose:    provide overlbel effect for input box
 * @Scope:      jQuery
 */
jQuery.fn.overlabel = function () {
    this.each(function () {
        var label = AJS.$(this).removeClass("overlabel").addClass("overlabel-apply show").click(function () {
            AJS.$("#" + AJS.$(this).attr("for")).focus()
        });
        var field = AJS.$("#" + label.attr("for")).focus(function () {
            label.removeClass("show").hide()
        }).blur(function () {
            if (AJS.$(this).val() === "") {
                label.addClass("show").show()
            }
        });
        if (field.val() !== "") {
            label.removeClass("show").hide()
        }
    });
    return this
};